﻿using HCore;

namespace MEat
{
    public partial class MEatGame : HGame
    {
        public StateMachine<MEatGame> stateMachine => _stateMachine;

        private readonly StateMachine<MEatGame> _stateMachine;

        public MEatGame(LaunchParams launchParams) : base(launchParams)
        {
            Log("Init MEat Game!");
            _stateMachine = new StateMachine<MEatGame>(this);
            _stateMachine.SetGlobalState<ClientGlobalState>();

            if (launchParams.recordData != null)
                _stateMachine.ChangeState<ClientBattleState>();
            else
                _stateMachine.ChangeState<ClientConnectState>();
        }

        public override void Update()
        {
            networkMgr.Update();
            networkMgr.Input();
            _stateMachine.Update();
        }

        public override void Dispose()
        {
            _stateMachine.Dispose();
            base.Dispose();
        }
    }
}